﻿<%@ Page Title="Mobilhjulskift.dk - Online betaling" ViewStateMode="Disabled" Language="C#" MasterPageFile="~/WebsiteSub.master" AutoEventWireup="true" CodeBehind="Betaling.aspx.cs" Inherits="TireService.Website.Betaling" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <meta http-equiv="X-UA-Compatible" content="IE=8" />

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div id="googleconversion">
    </div>

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <script type="text/javascript" language="javascript" src="https://betaling.curanet.dk/customers/curanet/js/openpaymentwindow.js">
    </script>


     <script type="text/javascript" language="javascript">

         function GoToPaymentGateway() {
             // Disable submit button to avoid dobbelt submitting
             btnGoToPayment.SetEnabled(false);

             callbackInitiateOnlinePayment.PerformCallback();

             // Show loadingpanel while doing postback
             LoadingPanel.Show();
         }

         function OnCallbackInitiateOnlinePaymentComplete(s, e) {

            var runBrowserVersion = true;
            if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6) {//Firefox
                //Allow
                runChromeVersion = false;
            } else if (navigator.userAgent.indexOf('Chrome') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Chrome') + 7).split(' ')[0]) >= 15) {//Chrome
                //Allow
                runBrowserVersion = true;
            } else if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Version') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Version') + 8).split(' ')[0]) >= 5) {//Safari
                //Allow
                runBrowserVersion = true;
            } else {
                // Block
                runBrowserVersion = true;
            }

            if (runBrowserVersion) {
                // Initiate payment posting form
                paymentsubmitform.innerHTML = e.result;

                document.forms[0].action = "https://betaling.curanet.dk/paymentwindow.php";
                document.forms[0].submit();
            } else {
                LoadingPanel.Hide();

                alert('Vores betalingsside har desværre problemer med at køre i Firefox. Prøv en anden browser eller lav indbetaling med netbank via indbetalingskortet. Vi beklager ulejligheden.');
            } 
         }

         function OnOnlinePaymentDoneComplete(s, e) {
             // TODO:
         }

         function OnOnlinePaymentFailedComplete(s, e) {
             // TODO:
         }

         function CallBackError(s, e) {
             
             //alert('Fejl opstod: ' + e.message);
         }

     </script>

    <dx:ASPxCallback ID="callbackInitiateOnlinePayment" ClientInstanceName="callbackInitiateOnlinePayment"
        runat="server" OnCallback="callbackInitiateOnlinePayment_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackInitiateOnlinePaymentComplete" />
    </dx:ASPxCallback>
    

    <div id="paymentsubmitform">
    </div>

    <div id="box1">
        <dx:ASPxPanel ID="pInvoiceAlreadyPaid" ClientInstanceName="pInvoiceAlreadyPaid" runat="server" Width="100%" Visible="false">
            <PanelCollection>
                <dx:PanelContent ID="PanelContent3" runat="server">
                
                    <h1>Betaling af faktura</h1>
                    <hr />
                    Den valgte faktura er allerede blevet betalt.<br />
                    <br />
                    Du finder din faktura på følgende link: <asp:HyperLink ID="lnkInvoice_AlreadyPaid" Target="_blank" runat="server"></asp:HyperLink><br />
                    <br />
                    De bedste hilsener<br />
                    Mobilhjulskift.dk<br />

                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxPanel>

        <!-- Panel when Customer is trying to pay an invoice online -->
        <dx:ASPxPanel ID="pInitiateOnlinePayment" ClientInstanceName="pInitiateOnlinePayment" runat="server" Width="100%" Visible="false">
            <PanelCollection>
                <dx:PanelContent ID="PanelContent5" runat="server">
                
                    <h1>Betaling af faktura</h1>
                    <hr />
                    <h3>Kundeoplysninger</h3>
                    <asp:Literal runat="server" ID="lCustomerInformation"></asp:Literal><br />
                    <br />
                    <h3>Faktura nr <asp:Literal runat="server" ID="lInvoiceId"></asp:Literal></h3>
                    Beløb til betaling: <asp:Literal runat="server" ID="lAmount"></asp:Literal> kr inkl. moms<br /><br />

                    Se faktura her: 
                    <asp:HyperLink ID="lnkInvoice" Target="_blank" runat="server"></asp:HyperLink>
                    <br />
                    <br />
                    <dx:ASPxButton ID="btnGoToPayment" ClientInstanceName="btnGoToPayment" runat="server" Text="Gå til betaling" AutoPostBack="False" UseSubmitBehavior="False">
                        <ClientSideEvents Click="function(s, e) { GoToPaymentGateway(); }" />
                    </dx:ASPxButton>                  

                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxPanel>

        <!-- Panel when system confirms payment of customer invoice -->
        <dx:ASPxPanel ID="pOnlinePaymentDone" ClientInstanceName="pOnlinePaymentDone" runat="server" Width="100%" Visible="false">
            <PanelCollection>
                <dx:PanelContent ID="PanelContent1" runat="server">
                    <dx:ASPxCallbackPanel ID="callbackOnlinePaymentDone" ClientInstanceName="callbackOnlinePaymentDone" runat="server" OnCallback="callbackOnlinePaymentDone_Callback" RenderMode="Table">
                        <ClientSideEvents EndCallback="OnOnlinePaymentDoneComplete" CallbackError="CallBackError" />
                        <PanelCollection>
                            <dx:PanelContent>
                                <h1>Betaling af faktura</h1>
                                <hr />
                                Registreringen af din betal er hermed godkendt.<br />
                                <br />
                                Du finder din faktura på følgende link: <asp:HyperLink ID="lnkInvoice_PaymentDone" Target="_blank" runat="server"></asp:HyperLink><br />
                                <br />
                                De bedste hilsener<br />
                                Mobilhjulskift.dk<br />
                                
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxPanel>

        <!-- Panel when error occured in payment transaction -->
        <dx:ASPxPanel ID="pOnlinePaymentFailed" ClientInstanceName="pOnlinePaymentFailed" runat="server" Width="100%" Visible="false" ViewStateMode="Disabled">
            <PanelCollection>
                <dx:PanelContent ID="PanelContent2" runat="server">
                    <dx:ASPxCallbackPanel ID="callbackOnlinePaymentFailed" ClientInstanceName="callbackOnlinePaymentFailed" runat="server" OnCallback="callbackOnlinePaymentFailed_Callback" RenderMode="Table">
                        <ClientSideEvents EndCallback="OnOnlinePaymentFailedComplete" CallbackError="CallBackError" />
                        <PanelCollection>
                            <dx:PanelContent>
                                Der opstod en fejl i betalingsprocessen.<br />
                                <br />
                                <dx:ASPxLabel ID="lblErrorMessage" runat="server" Text="">
                                </dx:ASPxLabel>
                                <br />
                                <br />
                                Venligst prøv igen via link du har modtaget på email eller kontakt vores kundesupport.<br />
                                <br />
                                De bedste hilsener<br />
                                Mobilhjulskift.dk<br />

                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxPanel>

        <!-- Panel when error occured -->
        <dx:ASPxPanel ID="pErrorPanel" ClientInstanceName="pErrorPanel" runat="server" Width="100%" Visible="false">
            <PanelCollection>
                <dx:PanelContent ID="PanelContent4" runat="server">
                    <h1>Fejl opstod</h1>

                    Der opstod en fejl:<br />
                    <br />
                    <dx:ASPxLabel ID="lblError" runat="server" Text="">
                    </dx:ASPxLabel>
                    <br />
                    <br />
                    Venligst prøv at udfør handlingen igen eller kontakt vores kundesupport.<br />
                    <br />
                    De bedste hilsener<br />
                    Mobilhjulskift.dk<br />

                            
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxPanel>
    </div>

</asp:Content>
